package com.mcflies.ui;

import com.mcflies.commons.McfliesConstant;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

/**
 * @author:mcfly_jun
 * @create_date:2012-8-8
 * @comment:Android每日学习主目录
 */
public class DailyLearningActivity extends Activity {
	private ListView lv;
	private String[] dailyLearningActivityItemName;
	private String[] dailyLearningActivityItem;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		setContentView(R.layout.daily_learning_main);
		initWidget();
		initData();
		lv.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1,
				dailyLearningActivityItemName));
		lv.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View view,
					int position, long id) {
				try {
					Intent intent = new Intent(DailyLearningActivity.this,
							Class.forName(dailyLearningActivityItem[position]));
					startActivity(intent);
				} catch (Exception e) {
					Log.i(McfliesConstant.MCFLIES_EXCEPTION_INFO_FLAG,
							e.getMessage());
				}
			}
		});
	}

	private void initWidget() {
		lv = (ListView) findViewById(R.id.daily_learning_main_lv);
	}

	private void initData() {
		dailyLearningActivityItemName = getResources().getStringArray(
				R.array.dailyLearningActivityItemName);// 获取values文件夹中的声明的Array数组
		dailyLearningActivityItem = getResources().getStringArray(
				R.array.dailyLearningActivityItem);
	}
}